package Mypackage;

import Mypackage.KY4_1_YMD; //引用 Mypackage 包中的 KY4_1_YMD 类
public class KY4_2 
{ 
      private String name; 
      private KY4_1_YMD birth; 
public static void main(String args[]) 
      { 
          KY4_2 a = new KY4_2("张驰",1990,1,11); 
          a.output(); 
      } 
      public KY4_2(String n1,KY4_1_YMD d1) 
      { 
          name = n1; 
          birth = d1; 
      } 
      public KY4_2(String n1,int y,int m,int d) 
      { 
          this(n1,new KY4_1_YMD(y,m,d));//初始化变量与对象 
      } 
      public int age()                                   //计算年龄 
      { 
          return KY4_1_YMD.thisyear() - birth.year(); //返回当前年与出生年的差即年龄 
      } 
      public void output() 
      { 
          System.out.println("姓名 : "+name); 
          System.out.println("出生日期: "+birth.toString()); 
          System.out.println("今年年龄 : "+age()); 
      } 
  } 
